<?php
    if (!defined('EXPONENT')) exit('');
    if (exponent_users_isAdmin() ||  exponent_permissions_check(array("administrate"),$loc))
    {
        exponent_flow_set(SYS_FLOW_PROTECTED,SYS_FLOW_ACTION);
        require_once(BASE."modules/formhelpermodule/formhelper.php");
        $formhelper=new formhelper("mailinglistmodule","_mail_manager_register_title","_Manager_Email",$loc);
        $formhelper->setGridType(FORMHELPER_GRID_TYPE_DATAGRID);
        $formhelper->setGridOptions("height",500);
        $formhelper->setGridOptions("idField","id");
        $formhelper->setGridOptions("pagination",1);
        $formhelper->setGridOptions("pageNumber","1");
        $formhelper->setGridOptions("pageSize","20");
        $formhelper->setGridOptions("rownumbers","true");
        $formhelper->setGridOptions("singleSelect","true");
        $formhelper->setGridID("mail_register");
        $formhelper->setInitCallback("TestGridCallback");
        $js=URL_FULL."modules/mailinglistmodule/js/Email_Manager_Regiter.js";
        $formhelper->addJS($js);
        $formhelper->setColumnType(1);
        $formhelper->addColumn(array("field"=>"email","title"=>"Email",'width'=>300));
        $formhelper->addColumn(array("field"=>"blacklist","title"=>"Blacklist",'width'=>100,'formatter'=>"function(value){if (value==0) return 'No'; else return 'Yes';}"));
        $formhelper->addColumn(array("field"=>"user_id","title"=>"User Type",'width'=>100,'formatter'=>"function(value){if (value==1) return 'Normail'; else return 'Maillinglist';}"));
        $link_param="/index.php?module=mailinglistmodule&action=email_manager_register_getjson&src={$loc->src}&ajax_action=1";
        $formhelper->setURLDataStream($link_param);
        $formhelper->setGridOptions("onBeforeLoad","function(___form_onBeforeLoad"); 
        $formhelper->setGridOptions("onSelect","function(___Blacklist_Email_OnSelect");
        $toolbar_template=new template("mailinglistmodule","_Email_Manager_Register_ToolbarHTML",$loc);
        $toolbar_template->register_permissions(array('administrate',"configure"),$loc);
        $toolbar_html=$toolbar_template->render();
        $formhelper->addToolbarHTML($toolbar_html); 
        $formhelper->setPreInitJSCall("form_mail_register_preinit"); 
        $formhelper->register_permissions(array('administrate',"configure"),$loc);
        $formhelper->output();
    }
    else
    {
        echo SITE_403_HTML;
    }
?>
